/*
 * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SLE_LITE_TOOL_SSAP_CLIENT_H
#define SLE_LITE_TOOL_SSAP_CLIENT_H

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

#include "kh_sle_ssap_client.h"
#include "cmd_input.h"
#include "sle_hilog.h"

#include <stdio.h>
#include <string.h>
#include <stdint.h>

#ifdef __LITEOS_M__
#include "common_tool.h"
#include "ohos_init.h"
#include "cmsis_os2.h"
#include "utils_file.h"
#endif // __LITEOS_M__

void OnSleTFindStructureCb(uint8_t clientId, uint16_t connectId
        , const ClientFindServiceRes *service, SleErrorCode errCode);
void OnSleTFindPropertyCb(uint8_t clientId, uint16_t connectId
        , const ClientFindPropertyRes *property, SleErrorCode errCode);
void OnSleTReadCfmCb(uint8_t clientId, uint16_t connectId
        , const ClientHandleValue *readData, SleErrorCode errCode);
void OnSleTWriteCfmCb(uint8_t clientId, uint16_t connectId
        , const ClientWriteRes *writeResult, SleErrorCode errCode);
void OnSleTExchangeInfoCb(uint8_t clientId, uint16_t connectId
        , const SsapMtuInfo *exchangeInfo, SleErrorCode errCode);
void OnSleTNotificatedCb(uint8_t clientId, uint16_t connectId
        , const ClientHandleValue *data, SleErrorCode errCode);
void OnSleTIndicatedCb(uint8_t clientId, uint16_t connectId
        , const ClientHandleValue *data, SleErrorCode errCode);
static SleSsapcCallbacks g_ssapcToolCbs = {
    .OnSleFindStructureCb = OnSleTFindStructureCb,
    .OnSleFindPropertyCb = OnSleTFindPropertyCb,
    .OnSleReadCfmCb = OnSleTReadCfmCb,
    .OnSleWriteCfmCb = OnSleTWriteCfmCb,
    .OnSleExchangeInfoCb = OnSleTExchangeInfoCb,
    .OnSleNotificatedCb = OnSleTNotificatedCb,
    .OnSleIndicatedCb = OnSleTIndicatedCb,
};
uint8_t GetSleToolSsapClientId(void);
void TAddSspaClient(void);
void TRemoveClient(void);
void TFindSsapStructure(void);
void TSendReadReqByUuid(void);
void TSendReadReq(void);
void TSendWriteReq(void);
void TSendWriteCmd(void);
void TSendExchangeInfoReq(void);
void SleSsapClientToolHalper(void);

static CmdNode g_ssapClientCmdList[] = {
    //sle_ssap_client_test
    {"SleSsapClientHalper", SleSsapClientToolHalper},
    {"AddSsapClient", TAddSspaClient},
    {"RemoveClient", TRemoveClient},
    {"FindSsapStructure", TFindSsapStructure},
    {"SendReadReqByUuid", TSendReadReqByUuid},
    {"SendReadReq", TSendReadReq},
    {"SendWriteReq", TSendWriteReq},
    {"SendWriteCmd", TSendWriteCmd},
    {"SendExchangeInfoReq", TSendExchangeInfoReq},
};

static uint16_t g_ssapClientCmdNum = sizeof(g_ssapClientCmdList) / sizeof(CmdNode);
void SleSsapClientToolCmdHandler(int argc, char **argv);

#ifdef __cplusplus
}
#endif // __cplusplus

#endif //SLE_LITE_TOOL_SSAP_CLIENT_H